package com.bcxk.config;

import com.bcxk.interceptor.MinSuInterceptor;
import com.bcxk.resolver.ArgumentResolver;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.mvc.method.annotation.ServletWebArgumentResolverAdapter;

import java.util.List;


@Configuration
public class WebConfig extends WebMvcConfigurationSupport {

    //配置参数解析器
    @Override
    protected void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        argumentResolvers.add(new ServletWebArgumentResolverAdapter(new ArgumentResolver()));
    }



    //配置spring的拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(new MinSuInterceptor());
        interceptorRegistration.addPathPatterns("/**");
        super.addInterceptors(registry);
    }

}
